//package mobi.workflowengine.core;
//
//public class WorkflowMessageActivity {
//
//}

package mobi.workflowengine.core;

import java.util.Timer;
import java.util.TimerTask;

import mobi.workflowengine.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.widget.TextView;

public class WorkflowMessageActivity extends Activity {
	
	public TimerTask workflowMessageChannelMonitorTask;
	static private String messages = "";

	static void addMessage(String message)
	{
		if(message.length()>0)
			messages+=  message;
		else
			messages = message;
	}
	static void clearMessage()
	{
		messages = "";
	}
	
	
	public static void closeIt()
	{
		if(topOne!=null)
		{
			topOne.runOnUiThread(new Runnable() {
				
				@Override
				public void run() {
					topOne.finish();
				}
			});
		}
	}
	
	public static void updateMessage() {
		
		if(topOne!=null)
		{
			topOne.runOnUiThread(new Runnable() {
				
				@Override
				public void run() {
					if(tvTxtworkflowMessage!=null)
	        			tvTxtworkflowMessage.setText(messages);
				}
			});
		}
	}
	

	
	static TextView tvTxtworkflowMessage;
	
	static boolean active = false;

    @Override
    public void onStart() {
       super.onStart();
       topOne = this;
       active = true;
    } 

    @Override
    public void onStop() {
    	topOne = null;
    	super.onStop();
       
       active = false;
    }
    
    public static boolean isRunning()
    {
    	return active;
    }
    
	int newMessage;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_workflow_notifications);
		topOne = this;
		tvTxtworkflowMessage = (TextView)findViewById(R.id.txtworkflowMessage);
		tvTxtworkflowMessage.setText(messages);		
	}
	
	static WorkflowMessageActivity topOne;
	
}
